package com.topvision.controller.app;

import com.topvision.model.glass.Sysversion;
import com.topvision.service.api.glass.AppSysVersionService;
import com.topvision.service.api.glass.AppVideoStreamService;
import com.topvision.util.R;
import com.topvision.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(value = "应用管理相关接口", description = "如版本更新查询")
@RequestMapping("app/sysversion")
public class AppSysVersionController {

    @Autowired
    AppSysVersionService appSysVersionService;


    @RequestMapping(value = "/getNewestVersion", method = RequestMethod.GET)
    @ApiOperation(value = "获取最新版本信息", produces = MediaType.APPLICATION_JSON_VALUE, notes = "通过包名和平台获取最新的版本信息", response = R.class)
    public R getNewestVersion(@RequestParam String packageName, @RequestParam String platform) {
        if (StringUtils.isEmpty(packageName)) {
            return R.error("包名不能为空");
        }
        if (StringUtils.isEmpty(platform)) {
            return R.error("平台不能为空");
        }
        Sysversion entity = appSysVersionService.getNewestVersion(packageName, platform);
        if (entity != null) {
            return R.success(entity);
        }
        return R.error("无相关信息");
    }
}
